package com.example.onlineeducation.viewmodel

import androidx.lifecycle.LiveData
import androidx.lifecycle.MutableLiveData
import com.example.onlineeducation.base.BaseViewModel
import com.example.onlineeducation.data.entity.ExamResultDetailEntity
import com.example.onlineeducation.repository.StudyRepository
import com.yc.jetpacklib.net.YcResult
import kotlinx.coroutines.flow.collectLatest

class ExamResultDetailVM : BaseViewModel() {
    private val mStudyRepository: StudyRepository by lazy { StudyRepository(mApiService) }


    private val _mExamResultDetail = MutableLiveData<YcResult<ExamResultDetailEntity>>()
    val mExamResultDetail: LiveData<YcResult<ExamResultDetailEntity>> = _mExamResultDetail

    fun getExamResultDetail(examLogId: String) =ycLaunch{
        mStudyRepository.getExamResultDetail(examLogId).ycHasLoading().collectLatest { result ->
            _mExamResultDetail.postValue(result)
        }
    }

}
